package com.xiaochong.tir.api.controller;

import com.xiaochong.tir.api.service.ShelSelectService;
import com.xiaochong.tir.api.util.ApiVersion;
import com.xiaochong.tir.common.data.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description: 1.2.1自选
 * @Author: org
 * @CreateDate: 2018/7/25 11:25
 */
@Api(value="自选1.2.1接口")
@RestController
@RequestMapping(ApiVersion.API_V1_PREFIX+"/ShelSelect")
public class ShelSelectController {

    @Autowired
    private ShelSelectService shelSelectService;

    @ApiOperation(value = "自选取消或加入自选", notes = "返回code：1000-成功；2000-无数据；5000-查询失败；3000-参数错误")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "1、为自选交易对；2、为自选货币", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "unique_annotation", value = "如果type为1，则为交易所交易对中间表id；如果type为2，则为货币表id", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "flagType", value = "1、插入；2、删除", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "userToken", value = "userToken用户token", required = true, dataType = "String", paramType = "query")
    })
    @GetMapping("/joinAndCancelShelSelect")
    public ApiResultVo joinAndCancelShelSelect(@RequestParam(value = "flagType") Integer flagType,@RequestParam(value = "type") Integer type,
                                               @RequestParam(value = "unique_annotation") Integer unique_annotation,
                                               @RequestParam("userToken") String userToken){
        return shelSelectService.joinAndCancelShelSelect(type,userToken,unique_annotation,flagType);
    }

    @ApiOperation(value = "行情k线-自选", notes = "返回code：1000-成功；2000-无数据；5000-查询失败；3000-参数错误")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageIndex", value = "当前页数", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "每页条数", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "userToken", value = "userToken用户token", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型desc降序、asc升序", required = false, dataType = "String", paramType = "query")
    })
    @GetMapping("/kActionMarketSelfSelect")
    public ApiResultVo<List<ApiKActionQuantizationVo>> kActionMarketSelfSelect(@RequestParam(value = "pageIndex") Integer pageIndex,@RequestParam(value = "pageSize") Integer pageSize,
                                                                               @RequestParam(value = "userToken")  String userToken,
                                                                               @RequestParam(value = "sortField",required = false) String sortField,
                                                                               @RequestParam(value = "sortType",required = false) String sortType){
        return shelSelectService.kActionMarketSelfSelect(pageIndex,pageSize,userToken,sortField,sortType);
    }

    /**
     * 货币行情-自选
     */
    @ApiOperation(value = "货币行情-自选" , notes = "返回code：1000-成功；2000-无数据；5000-查询失败；3000-参数错误")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageIndex", value = "当前页数", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "每页条数", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "userToken", value = "userToken用户token", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型desc降序、asc升序", required = false, dataType = "String", paramType = "query")
    })
    @GetMapping("currencyQuotationSelfSelect")
    public ApiResultVo<List<CurrencyQuotationResultVo>> currencyQuotationSelfSelect(@RequestParam(value = "pageIndex") Integer pageIndex,@RequestParam(value = "pageSize") Integer pageSize,
                                                                                    @RequestParam(value = "userToken") String userToken,
                                                                                    @RequestParam(value = "sortField",required = false) String sortField,
                                                                                    @RequestParam(value = "sortType",required = false) String sortType){
        return shelSelectService.currencyQuotationSelfSelect(pageIndex,pageSize,userToken,sortField,sortType);
    }
}
